package lab02.Test23;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Scanner;

import java.util.Calendar;

public class Test {
    public static void main(String[] args) throws ParseException {
        //1.键盘输入生日2017-11-02
        Scanner scanner = new Scanner(System.in);
        String  birthday;
        birthday = scanner.nextLine();

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd");
        Calendar calendar = Calendar.getInstance();

        long time1 = 0;
        long time2 = 0;

        calendar.setTime(simpleDateFormat.parse(birthday));
        time1 = calendar.getTimeInMillis();

        calendar.setTime(simpleDateFormat.parse("2017-11-02"));
        time2 = calendar.getTimeInMillis();

        System.out.println("相差天数是：" + (time1 - time2)/(24*60*60*1000));


        //编写Java应用程序，从命令行输入你的生日信息，然后计算你的生日还有多少天，你的生日是星期几。
        Calendar time =Calendar.getInstance();

        Scanner scan=new Scanner(System.in);

        int year,month,day;

        System.out.println("出生年:");

        year=scan.nextInt();

        System.out.println("出生月:");

        month=scan.nextInt();

        System.out.println("出生日:");

        day=scan.nextInt();



        time.set(year, month-1, day);//月份是从0开始的,所以减一

        int Day=time.get(Calendar.DAY_OF_WEEK);//DAY_OF_WEEK是获取当前日期是一周中的第几天

        System.out.println("星期"+(Day-1));//每周从星期天算起，所以减一
    }

}

